<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue组件插槽</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>

<body>
    <div id="Application">
        <my-container2>
            <template #header>
                <h1>这里是头部元素</h1>
            </template>

            <template #main>
                <p>内容部分1</p>
                <p>内容部分2</p>
            </template>

            <template #footer>
                <p>这里是尾部元素</p>
            </template>
        </my-container2>
    </div>
    <script>
        const App = Vue.createApp({
        })

        // 注意什么位置的颜色才能生效
        const container2Component = {
            template: `
            <div>
                <div style="color:grey">
                    <slot name="header" style="color:red"></slot>
                </div>

                <hr/>
                
                <slot name="main" style="color:green"></slot>
                
                <hr/>
                
                <slot name="footer" style="color:blue"></slot>
            </div>
            `
        }
        App.component("my-container2", container2Component)

        const containerComponent = {
            template: `
            <div style="border-style:solid;border-color:red; border-width:10px">
                <slot>插槽的默认内容</slot>
            </div>
            `
        }
        App.component("my-container", containerComponent)

        App.mount("#Application") 
    </script>
</body>

</html>